<template>
  <div class="app-container">
    <div class="text">
      预警消息设置
    </div>
    <div class="main text">
      <span>商户金额不足</span>
      <el-input v-model="warningValue" placeholder="请输入金额" style="width: 70px;"></el-input>
      <span>元进行消息通知</span>
    </div>
    <el-button type="primary" @click="submitForm">保 存</el-button>
  </div>
</template>

<script>
import { listBalanceWarning, getBalanceWarning, delBalanceWarning, addBalanceWarning, updateBalanceWarning } from "@/api/messages/balanceWarning";

export default {
  name: "BalanceWarning",
  dicts: ['sys_agent'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 消息设置表格数据
      warningValue: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        warningValue: null,
        type: null,
        status: null,
        userId: null,
        deptId: null
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询消息设置列表 */
    getList() {
      this.loading = true;
      listBalanceWarning(this.queryParams).then(response => {
        this.warningValue = response.rows[0].warningValue;
        this.loading = false;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.form.warningValue = this.warningValue;
      updateBalanceWarning(this.form).then(response => {
        this.$modal.msgSuccess("保存成功");
      });
      // this.$refs["form"].validate(valid => {
      //   if (valid) {
      //     if (this.form.id != null) {
      //       updateBalanceWarning(this.form).then(response => {
      //         this.$modal.msgSuccess("修改成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     } else {
      //       addBalanceWarning(this.form).then(response => {
      //         this.$modal.msgSuccess("新增成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     }
      //   }
      // });
    },

  }
};
</script>

<style lang="scss" scoped>
  .main {
    margin: 20px;
    .el-input {
      margin: 0 5px;
    }
  }
  .text {
    font-weight: 400;
    font-size: 16px;
    color: #333333;
  }
</style>
